package cn.itsource.ymjs.web.controller;

import cn.itsource.ymjs.entity.FitnessCourse;
import cn.itsource.ymjs.query.CourseQuery;
import cn.itsource.ymjs.result.JSONResult;
import cn.itsource.ymjs.service.IFitnessCourseService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/fitnessCourse")
@Api
public class FitnessCourseController  extends BaseController<FitnessCourse, CourseQuery>{

    @Autowired
    private IFitnessCourseService fitnessCourseService;

    @GetMapping("/allFitness")
    public JSONResult getAllCourse() {
        List<FitnessCourse> list = fitnessCourseService.getAllCourse();
        return JSONResult.success(list);
    }

    @PostMapping("/save")
    public JSONResult save(@RequestBody FitnessCourse fitnessCourse) {
        fitnessCourseService.save(fitnessCourse);
        return JSONResult.success();

    }

    @PutMapping("/online")
    private JSONResult online(@RequestBody List<Long> ids) {

        return fitnessCourseService.online(ids);
    }
    @PutMapping("/offline")
    private JSONResult offline(@RequestBody List<Long> ids) {

        return fitnessCourseService.offline(ids);
    }
}
